package vmcs.simulationsystem;

// Copyright 1997 ISS.
// The contents contained in this document may not be reproduced in any
// form or by any means, without the written permission of ISS, other
// than for the purpose for which it has been supplied.
//
// Author: Olivo Miotto
//
//

import java.awt.*;
import java.awt.event.*;

import vmcs.common.*;
import vmcs.controller.*;
import vmcs.ui.interfacecontrol.*;



public class SimulatorControlPanel implements ISimulatorPanel{
    private Button buttons[];
    private Frame frame;
    private MainController mainCtrl;

	public SimulatorControlPanel () {
    }

	public Button[] getButtons() {
		return buttons;
	}

	public void setButtons(Button[] buttons) {
		this.buttons = buttons;
	}

    public MainController getMainCtrl() {
		return mainCtrl;
	}

	public void setMainCtrl(MainController mainCtrl) {
		this.mainCtrl = mainCtrl;
	}

	@Override
    public void display(){
		frame.setVisible(true);
    }

    public void setButtonState (int id, boolean state) {
        buttons[id].setEnabled (state);
    }

	@Override
    public void closeDown () {
		frame.dispose ();
    }

    public Frame getFrame() {
		return frame;
	}

	public void setFrame(Frame frame) {
		this.frame = frame;
	}

	public void stop(){
        mainCtrl.closeDown();
    }

	@Override
	public void setPanelActive(boolean isOn) {
		setButtonState (Constant.SIMUL_BEGIN,   !isOn);
        setButtonState (Constant.ACT_MAINTAINER, isOn);
        setButtonState (Constant.ACT_MACHINERY,  isOn);
        setButtonState (Constant.ACT_CUSTOMER,   isOn);
        setButtonState (Constant.SIMUL_END,      isOn);
		
	}

	@Override
	public void setPanelActive(int panelId, boolean active) {
		setButtonState(panelId, active);
		
	}
}